package com.wang.controller;

import com.wang.entity.Detail;
import com.wang.service.DetailService;
import com.wang.utils.PageUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Classname Detail
 * @Description TODO
 * @Date 2024/11/11 8:56
 * @Created by pc
 */
@RestController
@RequestMapping("/detail")
public class DetailController {
    @Resource
    private DetailService detailService;

    @RequestMapping
    public PageUtil<Detail> find(@RequestParam(value = "sid",required = false) Integer sid,
                                 @RequestParam(value = "pageNo") Integer pageNo, Integer pageSize){
        return detailService.find(sid,pageNo,2);

    }

    @RequestMapping("/find/{id}")
    public Detail findById(@PathVariable("id") Long id){
        return detailService.findById(id);
    }

    @RequestMapping("/update")
    public Map<String,Object> update(Detail detail, Integer count){
        return detailService.update(detail,count);
    }
}
